<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>${siteName!""}|座位管理-${title!""}</title>
  <#include "../common/header.ftl"/>
  <style>
    td{
      vertical-align:middle;
    }
  </style>
</head>

<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <aside class="lyear-layout-sidebar">

      <!-- logo -->
      <div id="logo" class="sidebar-header">
        <a href="index.html"><img src="/admin/images/logo-sidebar.png" title="${siteName!""}" alt="${siteName!""}" /></a>
      </div>
      <div class="lyear-layout-sidebar-scroll">
        <#include "../common/left-menu.ftl"/>
      </div>

    </aside>
    <!--End 左侧导航-->

    <#include "../common/header-menu.ftl"/>

    <!--页面主要内容-->
    <main class="lyear-layout-content">

      <div class="container-fluid">

        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <form class="pull-right search-bar" method="get" action="list" student="form">
                  <div class="input-group">
                    <div class="input-group-btn">
                      <button class="btn btn-default dropdown-toggle" id="search-btn" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                        阅览室名称 <span class="caret"></span>
                      </button>
                      <ul class="dropdown-menu">
                        <li> <a tabindex="-1" href="javascript:void(0)" data-field="title">阅览室名称</a> </li>
                      </ul>
                    </div>
                    <input type="text" class="form-control" value="${name!""}" name="name" placeholder="请输入阅览室名称">
                    <span class="input-group-btn">
                      <button class="btn btn-primary" type="submit">搜索</button>
                    </span>
                  </div>
                </form>
                <#include "../common/third-menu.ftl"/>
              </div>
              <div class="card-body">

                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                    <tr>
                      <th>
                        <label class="lyear-checkbox checkbox-primary">
                          <input type="checkbox" id="check-all"><span></span>
                        </label>
                      </th>
                      <th>座位创建时间</th>
                      <th>阅览室名称</th>

                    </tr>
                    </thead>
                    <tbody>
                    <#if pageBean.content?size gt 0>
                      <#list pageBean.content as seatDTO>
                        <tr>
                          <td style="vertical-align:middle;">
                            <label class="lyear-checkbox checkbox-primary">
                              <input type="checkbox" name="ids[]" value="${seatDTO.readingRoom.id}" seat-data="${seatDTO.getCreateTime()!""}">
                              <span></span>
                            </label>
                          </td>
                          <td style="vertical-align:middle;">
                            ${seatDTO.getCreateTime()!"座位尚未创建"}
                          </td>
                          <td align="center">${seatDTO.getReadingRoom().getName()}</td>
                        </tr>
                      </#list>
                    <#else>
                      <tr align="center"><td colspan="5">这里空空如也！</td></tr>
                    </#if>
                    </tbody>
                  </table>
                </div>
                <#if pageBean.total gt 0>
                  <ul class="pagination">
                    <#if pageBean.currentPage == 1>
                      <li class="disabled"><span>«</span></li>
                    <#else>
                      <li><a href="list?name=${name!""}&currentPage=1">«</a></li>
                    </#if>
                    <#list pageBean.currentShowPage as showPage>
                      <#if pageBean.currentPage == showPage>
                        <li class="active"><span>${showPage}</span></li>
                      <#else>
                        <li><a href="list?name=${name!""}&currentPage=${showPage}">${showPage}</a></li>
                      </#if>
                    </#list>
                    <#if pageBean.currentPage == pageBean.totalPage>
                      <li class="disabled"><span>»</span></li>
                    <#else>
                      <li><a href="list?name=${name!""}&currentPage=${pageBean.totalPage}">»</a></li>
                    </#if>
                    <li><span>共${pageBean.totalPage}页,${pageBean.total}条数据</span></li>
                  </ul>
                </#if>
              </div>
            </div>
          </div>

        </div>

      </div>

    </main>
    <!--End 页面主要内容-->
  </div>
</div>
<#include "../common/footer.ftl"/>
<script type="text/javascript" src="/admin/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/admin/js/main.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){

  });

  //打开选座页面
  function choose(url){
    var checked = $("input[type='checkbox']:checked");

    if(checked.length != 1){
      showWarningMsg('请选择一个阅览室进行选座！');
      return;
    }

    if (checked.attr("seat-data") == "") {
      showWarningMsg('座位还未创建！');
      return;
    }



    var date = new Date().getTime()+(1000 * 60 * 60 * 24); // 获取时间戳
    window.location.href = url +'?date=' + date + '&timeCode='+ 1 + '&id=' + checked.val();
  }

  //打开座位状态修改页面
  function able(url){
    var checked = $("input[type='checkbox']:checked");

    if(checked.length != 1){
      showWarningMsg('请选择一个阅览室进行座位状态管理！');
      return;
    }

    if (checked.attr("seat-data") == "") {
      showWarningMsg('座位还未创建！');
      return;
    }

    window.location.href = url +'?id=' + checked.val();
  }






  function add(url){
    var checked = $("input[type='checkbox']:checked");

    if(checked.length != 1){
      showWarningMsg('请选择一条数据进行添加！');
      return;
    }

    var id = checked.val();
    ajaxRequest(url,'post',{id:id},function(rst){
      if(rst.code == 0){
        showSuccessMsg('座位生成成功！',function(){
          window.location.reload();
        });
      }else {
        showErrorMsg(rst.msg);
      }

    });

  }
</script>
</body>
</html>